package com.qf.controller;

import com.qf.pojo.Order;
import com.qf.pojo.resp.BaseResult;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Package: com.qf.controller
 * @ClassName: OrderController
 * @Author: lmr
 * @CreateTime: 2021/9/11 17:36
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 添加订单
     * @param order
     * @return
     */
    @RequestMapping("/addOrder")
    public BaseResult addOrder(@RequestBody Order order){
        BaseResult baseResult = orderService.addOrder(order);
        return baseResult;
    }

    /**
     * 根据用户id查询用户订单
     * @param uid
     * @return
     */
    @RequestMapping("/findOrderByUid/{uid}")
    public BaseResult findOrderByUid(@PathVariable("uid" )Integer uid){
        BaseResult baseResult = orderService.findOrderByUid(uid);
        return baseResult;
    }
    /**
     * 根据订单oid删除订单
     * @param oidList
     * @return
     */
    @RequestMapping("/delOrderById")
    public BaseResult delOrderById(@RequestParam("oidList") List<String> oidList){
        //System.out.println(oidList);
        BaseResult baseResult = orderService.delOrderById(oidList);
        return baseResult;
    }
}
